<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div style="padding: 10px;">
	<form class="op-form" id="addForm" name="addForm" method="post">
		<table>
			<tr>
				<td>用户名:</td>
				<td>
					<input class="easyui-validatebox" name="code" required="true" validType="length[2,12]">
				</td>
			</tr>
			<tr>
				<td>姓名:</td>
				<td>
					<input class="easyui-validatebox" name="name" required="true" validType="chinese;length[2,4]" maxlength="4">
				</td>
			</tr>
			<tr>
				<td>身份证:</td>
				<td>
					<input class="easyui-validatebox" name="idCode" required="true" validType="length[18,18]" maxlength="18">
				</td>
			</tr>
			<tr>
				<td>手机:</td>
				<td>
					<input class="easyui-validatebox" name="phone" required="true" validType="mobile" maxlength="11">
				</td>
			</tr>
			<tr>
				<td>支付宝:</td>
				<td>
					<input class="easyui-validatebox" name="payCode" required="true" validType="bank">
				</td>
			</tr>
			<tr>
				<td>银行账号:</td>
				<td>
					<input class="easyui-validatebox" name="bankCode" required="true" validType="bank">
				</td>
			</tr>
			<tr>
				<td>邮件地址:</td>
				<td>
					<input class="easyui-validatebox" name="email" required="false" validType="email">
				</td>
			</tr>
			<tr>
				<td>
					<a id="btnSubmit" href="#" class="easyui-linkbutton" icon="icon-ok" onclick="$('#addForm').submit()">提交</a>
				</td>
				<td>
					<a href="#" class="easyui-linkbutton" icon="icon-cancel" onclick="addForm.reset()">重置</a>
					<a href="#" class="easyui-linkbutton" icon="icon-redo" onclick="$('#dataGrid').show();$('#opPanel').panel('close');">返回</a>
				</td>
			</tr>
		</table>
	</form>
</div>

<script type="text/javascript">
	
	$(document).ready(function(){
		$('#addForm').form({
			onSubmit: function(){
				if($(this).form('validate')){
					$("#btnSubmit").linkbutton({disabled:true});
					ajaxAdd();
				}else{
					return false;
				}
			}
		});
	});
	
	function ajaxAdd(){
		var actionURL = "agent.action?command=add";
		var params = jQuery("#addForm").dataForAjax().data;
			
		jQuery.ajax({
			url: actionURL,
			type: "post",
			cache: false,
			data: params,
			success: function(result){
				if("true" == result){
					$.messager.alert("友情提示", "您的操作成功!", "info", function(){
						$('#tt').datagrid('reload');
						$("#dataGrid").show();
						$("#opPanel").panel('close');
					});
				}else{
					$.messager.alert("友情提示", "您的操作失败!", "error");
				}
			}
		});
	}
</script>